package test;

import java.util.*;

public class Dame1_1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		//定义ArrayList对象
		ArrayList al=new ArrayList();
		//打印ArrayList的大小
		System.out.println("al大小："+al.size());
		//向al中加入数据（类型Object）
		//创建一个职员
		Clerk clerk1= new Clerk("宋江", 40, 2000);
		Clerk clerk2=new Clerk("吴用",40,3000);
		Clerk clerk3=new Clerk("林冲",23,3400);
		
		//将clwek1加进al
		al.add(clerk1);
		al.add(clerk2);
		al.add(clerk3);
		al.add(clerk1);
		//打印ArrayList的大小
		System.out.println("al大小："+al.size());
		 
		
			for(int i=0;i<al.size();i++){
				//如何访问al中的对象
				Clerk temp=(Clerk) al.get(i);
				System.out.println(temp.getName());
		}
			//如何删除al中的对象
			al.remove(3);
			for(int i=0;i<al.size();i++){
				//如何访问al中的对象
				Clerk temp=(Clerk) al.get(i);
				System.out.println(temp.getName());
		}
	}	
}

//定义一个员工类	
class Clerk {
	private String name;
	private int age;
	private float sal;
	public Clerk(String name,int age,float sal ){
		this.name=name;
		this.age=age;
		this.sal=sal;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public float getSal() {
		return sal;
	}
	public void setSal(float sal) {
		this.sal = sal;
	}
}
